import cn.yunhe.dao.BookDao;
import cn.yunhe.entity.Book;
import cn.yunhe.services.IBookService;
import cn.yunhe.services.impl.BookService;
import cn.yunhe.utils.SqlSessionFactoryUtil;
import net.sf.json.JSONArray;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.ArrayList;
import java.util.List;

public class Quary {
    SqlSession session= SqlSessionFactoryUtil.getSession();
    BookDao bookDao=session.getMapper(BookDao.class);
    IBookService iBookService=new BookService();
    List<Book> list=new ArrayList<>();
    JSONArray jsonArray=new JSONArray();
    @Test
    public void test1(){
        String keyword="李白";
        list=bookDao.getBookByAuthor(keyword);
        for (Book b:list
             ) {
            System.out.println(b.getBname());
        }
    }
    @Test
    public void test2(){
        String keyword="李白";
        jsonArray=iBookService.getBookByAuthor(keyword);
        System.out.println(jsonArray.get(0));
    }
}
